package aspectj;

/**
 * 切面类
 */
public aspect MyAspectJDemo {
    //target对应在Helloword里边的helloService
    pointcut authCheck(HelloService h):call(* HelloService.sayHelloTo(..)) && target(h);
    before(HelloService h ):authCheck(h){
        System.out.println("sayHello target方法执行前验证权限"+h);
    }
    //this对应HelloService调用dao方法的helloService
    pointcut authCheckThis(HelloService h):call(* HelloDao.seeyou(..)) && this(h);
    before(HelloService h ):authCheckThis(h){
        System.out.println("sayHello this方法执行前验证权限"+h);
    }

    /**
     * 定义切点,日志记录切点
     */
    pointcut recordLog():call(* HelloWord.sayHello(..));
    /**
     * 定义后置通知
     */
    after():recordLog(){
        System.out.println("sayHello方法执行后记录日志");
    }
}